﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache" content="no-cache" />
    <title>App病例设置编辑</title>
    <link href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/ligerui-icons.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/Gray/css/all.css" rel="stylesheet" />
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js?v=@DateTime.Now.ToString("yyyyMMdd")"></script>
    <style>
        .gridtable {
            width: 100%;
            margin: 0px;
        }

            .gridtable td {
                height: 30px;
                line-height: 30px;
            }
    </style>
</head>
<body>
    <div style="margin:10px 0px;">
        <table class="gridtable">
            <tr>
                <td style="text-align:right; width:100px;">
                    字段：
                </td>
                <td>
                    <select id="txtTCId" name="TCId"></select>
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    类型：
                </td>
                <td>
                    <select id="txtType" name="Type">
                        <option value="0">文本框</option>
                        <option value="1">输入框</option>
                        <option value="10">双输入框</option>
                        <option value="11">时间输入框</option>
                        <option value="12">下拉输入框</option>
                        <option value="13">整数输入框</option>
                        <option value="2">下拉框</option>
                        <option value="20">双下拉框</option>
                        <option value="3">单选框</option>
                        <option value="4">多选框</option>
                        <option value="40">选择输入框（组合）</option>
                    </select>
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    归类：
                </td>
                <td>
                    <input type="text" id="txtUser_Control" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    说明：
                </td>
                <td>
                    <input type="text" id="Other_Constraint" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    权限：
                </td>
                <td>
                    <input type="text" id="txtPower_UserID" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    排序：
                </td>
                <td>
                    <input type="text" id="txtControl_Order" style="width:50px;" class="l-text" />
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    是否启用：
                </td>
                <td>

                    <input type="radio" id="txtStatus1" name="Status" class="l-radio" title="是" value="1" />是&nbsp;&nbsp;<input type="radio" id="txtStatus0" class="l-radio" name="Status" title="否" value="0" />否
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    父集：
                </td>
                <td>
                    <input type="text" id="txtUser_Control_Father" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    标签：
                </td>
                <td>
                    <input type="text" id="txtControl_Label" class="l-text" style="width:250px;" />
                    <font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center;padding-top:10px;">
                    <input id="btnSubmit" type="button" value="保存" class="l-button" style="background: skyblue;" onclick="save()" />&nbsp;&nbsp;&nbsp;
                    <input id="btnCancel" type="button" value="取消" class="l-button" onclick="closeDialog()" />
                </td>
            </tr>
            <tr></tr>
        </table>
        <input type="hidden" id="txtId" />
    </div>
    <script type="text/javascript">
        $(function () {
            setValue();
            setTimeout(function () {
                $(".l-dialog-winbtn .l-dialog-close").click(function () {
                    parent.window.location.reload();
                });
            }, 1000);
        });
        //获取修改数据
        function setValue() {
            if (Number("@ViewBag.Id") > 0) {
                $.ajax({
                    url: '/ChestPainCenter/AppCaseConfig/GetData?Id=' + "@ViewBag.Id" + '&ram=' + Math.random(),
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        if (data.Rows.length > 0) {
                            var row = data.Rows[0];
                            $('#txtId').val(row.Id);
                            $('#txtType').val(row.Type);
                            $('#txtUser_Control').val(row.User_Control);
                            $('#txtOther_Constraint').val(row.Other_Constraint);
                            $('#txtPower_UserID').val(row.Power_UserID);
                            $('#txtControl_Order').val(row.Control_Order);
                            $('#txtUser_Control_Father').val(row.User_Control_Father);
                            $('#txtControl_Label').val(row.Control_Label);
                            $('#txtStatus' + row.State).attr('checked', 'checked');
                            initSelext('txtTCId', row.TCId);
                        } else {
                            $.ligerDialog.error("获取数据失败！");
                        }
                    }
                });
            } else {
                initSelext('txtTCId');
            }
        }
        //关闭弹框
        function closeDialog() {
            parent.window.location.reload();
            frameElement.dialog.close();//关闭dialog
        }
        //保存
        function save() {
            $.post("/ChestPainCenter/AppCaseConfig/SaveData", {
                Id: $("#txtId").val(),
                Type: $("#txtType").val(),
                TCId: $("#txtTCId").val(),
                Name: $("#txtTCId").find("option:selected").text(),
                Table_Name: $("#txtTCId").find("option:selected").attr('data-table'),
                Column_Name: $("#txtTCId").find("option:selected").attr('data-column'),
                User_Control: $("#txtUser_Control").val(),
                Other_Constraint: $("#txtOther_Constraint").val(),
                Power_UserID: $("#txtPower_UserID").val(),
                Control_Order: $("#txtControl_Order").val(),
                User_Control_Father: $("#txtUser_Control_Father").val(),
                Control_Label: $("#txtControl_Label").val(),
                State: $("input[name='Status']:checked").val(),
                rnd: Math.random()
            }, function (data) {
                $.ligerDialog.alert(data);
                closeDialog();
            })
        }
        //获取下拉框数据
        function initSelext(selid, value) {
            $.ajax({
                url: '/ChestPainCenter/TableColumn/GetData?ram=' + Math.random(),
                cache: false,
                type: 'POST',
                success: function (data) {
                    var strVar = "<option value='0'></option>";
                    $.each(eval(data), function (i, a) {
                        strVar += '<option value="' + a.Id + '" data-table="' + a.TableName + '" data-column="' + a.ColumnName + '">' + a.Name + '</option>'
                    })
                    //console.log(strVar)
                    $("#" + selid).html(strVar);
                    if (value) {
                        $("#" + selid).val(value);
                    }
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
    </script>
</body>
</html>
